#pragma once

#include "isingleton.h"
#include "Application.h"
#include "ClockListener.h"
#include "ClockSource.h"
#include "MouseListener.h"
#include "Window.h"
#include "event.h"
namespace Core
{
	namespace Devices
	{

		typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8;

		struct MouseEvent
		{
		public:
			int x,y;
			bool left,middle,right,key4;

		};
		class MouseListener;
		class MouseSource :
			public Source<MouseSource,MouseListener,MouseEvent>,public ISingleton<MouseSource,WinApp::Window>,public ClockListener
		{
			LPDIRECTINPUTDEVICE8 lpMouse;
			MouseEvent m,pm;
			int m_up,m_down,m_left,m_right;
		public:
			MouseEvent& getEvent();
			MouseSource(WinApp::Window& win);
			virtual void OnClock(ClockListener::SourceType& t);
			void SetMousePosition(int x,int y)
			{
				m.x=x;m.y=y;
			}
			void SetMouseBoundary(int up,int down, int left, int right)
			{
				m_up=up;
				m_down=down;
				m_left=left;
				m_right=right;
			}
		public:
			~MouseSource(void);

		public:
			
		};
		class MouseListener :public MouseSource::ISource::IListener
		{

			typedef IListener Base;
		public:
			virtual void OnMouseEvent(SourceType& mouse)=0;
		protected:

			MouseListener():Base(&MouseListener::OnMouseEvent){};

		public:

			~MouseListener(void)
			{
			}
		};
	}
}